// const apiFlight=require("./apiRequest");

const axios = require('axios');
axios.default.defaults.baseURL = "http://192.168.50.41:8080/";

window.onload = async function () {
    for (var i = 0; i < 10; i++) {
        var Rand = Math.floor(Math.random() * 201) + 1;
        var Url = '/api/flight/' + Rand;
        try {
            const resp = await axios.get(Url);
            // console.log(resp.data);
            var c = document.getElementById('flight');
            c.innerHTML += '<tr><th>'+ resp.data['ID'] +'</th>' + '<th>'+ resp.data['Code'] +'</th>' + '<th>'+ resp.data['Source'] +'</th>' + '<th>'+ resp.data['Destination'] +'</th>' + '<th>'+ resp.data['StartTime'] +'</th>' + '<th>'+ resp.data['Spend'] +'</th></tr>';

        } catch (error) {
            console.error(error);
        }
    }
};